# 一些模型转换方法


def db_result_to_dict(db_result):
    return {
        "id": db_result.id,
        "bookNo": db_result.book_no,
        "bookName": db_result.book_name,
        "bookAuthor": db_result.book_author,
        "typeId": db_result.type_id,
        "fileId": db_result.file_id,
        "createDate": db_result.create_date.strftime("%Y-%m-%d %H:%M:%S"),
        "createUser": db_result.create_user,
        "updateDate": db_result.update_date.strftime("%Y-%m-%d %H:%M:%S"),
        "updateUser": db_result.update_user,
        "version": db_result.version,
        "typeName": db_result.type_name,
        "fileUrl": db_result.file_url
    }


def db_results_to_dict(db_result_list):
    datas = []
    for item in db_result_list:
        datas.append(db_result_to_dict(item))
    return datas



